
	******************************************************************
	**
	**
	**		NAME:		GUY GROSSMAN, YOTAM MARGALIT, TAMAR MITTS
	**		DATE: 		December 15, 2021
	**		PROJECT: 	Israel Hayom
	**		DETAILS: 	This code generates figure SI-12
	**		Version: 	Stata MP 16
	**
	******************************************************************
	
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**

clear
version 16
set scheme plotplain
set more off
ssc install plausexog

capture cd "~/dropbox/Israeli Newspapers Study/JOP_REPLICATION/Dataverse submission"

* bring in dataset

use "Data/yeshuvlong_final.dta"

* additional cleaning
	
replace israelhayom_percent_e=0 if israelhayom_percent_e==. & year<2007
replace israelhayom_percent=0 if israelhayom_percent==. & year<2007
replace israelhayom_percent_cumulative=0 if israelhayom_percent_cumulativ==. & year<2007

drop if area_num >25

keep if BIG_rightbloc!=.
tabulate year, gen(YEAR)

* gen a running number for election years 	
egen yr = group(year)
move yr year

gen lpop= log(potential)
gen ltd = log(travel_dist)

* generate turnout var
gen turnout = voters/potential
replace turnout = 1 if turnout>1
replace turnout = turnout*100
tab year, summ(turnout)

* population share by age group
gen pop_share1829 = pop_M_18_29 / pop_total 
gen pop_share3049 = pop_M_30_49 /pop_total
gen pop_share5065 = pop_M_50_65 /pop_total
gen pop_share66 = pop_M_66 / pop_total
gen pop_adult = pop_M_18_29 + pop_M_30_49 + pop_M_50_65 + pop_M_66
 
 foreach var in pop_share1829 pop_share3049 pop_share5065 pop_share66{
	replace `var'=0 if `var'<0
 }

tabstat ltd lpop age_median_08 matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66, by(yr)

corr ltd lpop age_median_08 potential matriccert_pcnt_08 europe_pcnt_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 if yr==4

* generate otherpapers var for attentativeness measure
egen otherpapers=rowtotal(maariv_percent haaretz_percent globes_percent marker_percent calcalist_percent israelpost_percent makorrishon_percent) if year==2006
	bysort area_num: egen otherpapers2006=max(otherpapers)
	drop otherpapers
	
* rename parties	
ren Pisrael_beitenu Pib
ren BIG_rightbloc BRB
ren israelhayom_percent_electionyear IHE

* rename instruments
ren secular_max IVsm
ren secular_max07H1 IVsm07H1
ren sec_max06h2_07H1 IVsm06h2_07H1

tabstat IVsm IVsm07H1 IVsm06h2_07H1,  by(year)
corr IVsm IVsm07H1 IVsm06h2_07H1
drop IVsm

bysort area_num: egen IVsm=mean(IVsm07H1)
bysort area_num: egen IVsmp=mean(IVsm06h2_07H1)
tabstat IVsm IVsmp, by(year)
drop IVsm07H1 IVsm06h2_07H1

* generate variable of base level of support for right bloc and Likud
foreach var in BRB RIGHTBLOC Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez turnout	{
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}

* use LERI score to calculate mean ideology support at baseline 
table year uniqueid if uniqueid<6, c(mean leri_score )	
foreach var in leri_AVscore leri_score{
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}
		
xtset uniqueid yr
sort uniqueid yr	
estimates drop _all

		
// define covariates
		
gl interactions i.yr#c.ltd i.yr#c.lpop i.yr#c.matriccert_pcnt_08 i.yr#c.europe_pcnt_08 i.yr#c.pop_share1829 i.yr#c.pop_share3049 i.yr#c.pop_share5065 i.yr#c.pop_share66 i.yr#c.religion_pcnt i.yr#c.asia_pcnt_08


gl covs ltd lpop religion_pcnt matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66  
su $covs	

xtset uniqueid yr

*******************************************
* create dataset: 4 elections periosds
******************************************* 

replace period ="1" if period==""
replace period ="1" if period=="2006"
replace period ="2" if period=="2009"
replace period ="3" if period=="2013"
replace period ="4" if period=="2015"
destring period, replace

sort uniqueid yr
tsset uniqueid yr

collapse area_num semel_yeshuv ALL_rightbloc RIGHTBLOC BRB IHE israelhayom_percent_cumulative yediot_percent Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez potential voters turnout religion_pcnt_08 ///
europe_pcnt_08  matriccert_pcnt_08 national_pop lpop age_median_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 ///
ltd travel_dist travel_time  IVym IVall IVsm IVsmp otherpapers2006 ///
leri_AVscore leri_score , by(uniqueid period)

lab define period 1 "Pre 2007" 2 "2009 elections" 3 "2013 elections" 4 "2015 elections", modify
lab value period period
tab period, m

sort uniqueid period
tsset uniqueid period

preserve
keep uniqueid national_pop period
keep if period==2
	tempfile pop
	sa "`pop'"	
restore
	
merge m:1 uniqueid using "`pop'", update
drop _m

sort uniqueid period

foreach var in IHE BRB RIGHTBLOC Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez turnout {
	gen l`var' = l.`var'
	gen `var'D1 = `var'-l.`var'
	gen l2`var' = l2.`var'
	gen `var'D2 = `var'-l2.`var'
	gen l3`var' = l3.`var'
	gen `var'D3 = `var'-l3.`var'
	drop l`var' l2`var' l3`var'
	}
	
* generate variable of base level of support for right bloc and Likud
foreach var in BRB RIGHTBLOC Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez turnout	leri_AVscore leri_score {
	gen `var'0 = `var' if period==1
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	}

su BRBPre PlikudPre RIGHTBLOCPre PlaborPre leri_AVscorePre leri_scorePre
	
* create an indicator of whther a locality votes more/less right to right parties compared to country median in pre-IH launch period
egen median_BRB   = median(BRB0)
gen right0 = BRB0 > median_BRB if period==1
bysort uniqueid: egen right=mean(right0)
tab right

drop median_BRB BRB0 RIGHTBLOC0 Plikud0 Plabor0 Pib0 Pkadima0 Pbaityehudi0 Pshas0 Pmerez0 turnout0

* create three level category for right, left and centrist locality based on baseline right block baseline vote share
xtile BRB0 = BRBPre if period==1 , n(3)
by uniqueid: egen BRBCat=mean(BRB0)
lab define BRBCat 1 "Left" 2 "Center" 3 "Right", modify
lab value BRBCat BRBCat
tabstat BRBPre, by(BRBCat)
drop BRB0

list IHED1 IHE israelhayom_percent_cumulative BRBD1 BRB period in 1/10 	

* create three level category for right, left and centrist locality based on LERI score
xtile LERI0 = leri_scorePre if period==1 , n(3)
by uniqueid: egen LERICat=mean(LERI0)
lab define LERICat 1 "Left" 2 "Center" 3 "Right", modify
lab value LERICat LERICat
drop LERI0
tab LERICat

xtile LERIAV0 = leri_AVscorePre if period==1 , n(3)
by uniqueid: egen LERIAVCat=mean(LERIAV0)
lab define LERIAVCat 1 "Left" 2 "Center" 3 "Right", modify
lab value LERIAVCat LERIAVCat
tabstat leri_scorePre leri_AVscorePre, by(LERIAVCat)
drop LERIAV0
tab LERIAVCat

* crate log IH and ihs IH
gen lIHE=log(IHE+1)
lab var lIHE "IH (log)"
*ihstrans IHE, c

ren israelhayom_percent_cumulative IHEC
replace IHEC= IHE if period==2

// analysis 

tsset uniqueid period
sort uniqueid period
	
// define covariates
gl interactions i.period#c.ltd i.period#c.lpop i.period#c.matriccert_pcnt_08 i.period#c.europe_pcnt_08 i.period#c.pop_share1829 i.period#c.pop_share3049 i.period#c.pop_share5065 i.period#c.pop_share66 i.period#c.religion_pcnt i.period#c.asia_pcnt_08
su $interactions

gl covs ltd lpop matriccert_pcnt_08 europe_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 asia_pcnt_08 religion_pcnt
su $covs

* sensitivity analysis: union of confidence interval (UCI) as per Conley et al. 2012

graph drop _all
	
ivregress 2sls BRBD2 (IHE= IVsm) BRBPre $covs if period==3 [aw=potential],  cl(area_num) 
local IHE  _b[IHE]
di `IHE'

# delimit ;
 plausexog uci BRBD2 (IHE= IVsm) if period==3 [aw=potential], gmin(-0.1) gmax(0.25) grid(5) level(.95) vce(cl area_num)  
 graph(IHE) title("Right bloc (2013)") ytitle(Estimated {&beta} for IH) text(0.33 0 "gamma=0", place(n))
 xtitle({&delta}) yline(0, lp(solid) lc(red)) yline(0.32) legend(off)  name(F1); 
 #delimit cr	


ivregress 2sls PlikudD2 (IHE= IVsm) BRBPre if period==3 [aw=potential],  cl(area_num) 
local IHE  _b[IHE]
di `IHE'

 # delimit ;
 plausexog uci PlikudD2 (IHE= IVsm) if period==3 [aw=potential], gmin(-0.1) gmax(0.25) grid(5) level(.95) vce(cl area_num)  
 graph(IHE) title("Likud (2013)") ytitle(Estimated {&beta} for IH) text(0.3 0 "gamma=0", place(n))
 xtitle({&delta}) yline(0, lp(solid) lc(red)) yline(0.29) legend(off) name(F2); 
 #delimit cr
 
 graph combine F1 F2, title(Sensitivity Analysis: Union of Confidence Interval)
	gr export "Figures/Fig_SI-12.pdf", replace

